/**
 * Created with IntelliJ IDEA.
 * Description:数据流中的中位数
 * User: wangxin
 * Date: 2024-12-18
 * Time: 21:56
 */
import java.util.*;


public class test {
    private ArrayList<Integer> arr = new ArrayList<>();
    public void Insert(Integer num) {
        if(arr.isEmpty()){
            arr.add(num);
        }else{
            int i = 0;
            for(;i < arr.size();i++){
                if(num <= arr.get(i)){
                    break;
                }
            }
            arr.add(i,num);
        }

    }

    public Double GetMedian() {
        int n = arr.size();
        int i = n / 2;
        if(n % 2==0){
            double a = arr.get(i);
            double b = arr.get(i-1);
            return (a+b)/2;
        }
        return (double)arr.get(i);
    }


}
